package Transforming_Observables

import (
	"encoding/json"
	"fmt"
	"github.com/reactivex/rxgo/v2"
)

// marshal的逆向方式
func Demo_Unmarshal() {
	fmt.Println("Demo_BufferWithCount###########################")
	observable := rxgo.Just(
		[]byte(`{"id":1}`),
		[]byte(`{"id":2}`),
	)().Unmarshal(json.Unmarshal,
		func() interface{} {
			return &customer{}
		})

	for item := range observable.Observe() {
		if item.Error() {
			fmt.Println("订阅：", item.E)
		}
		fmt.Println("订阅：", item.V)
	}
}
